/*
 * Copyright (c) 2023-2299 深圳市阿毛科技有限公司 All rights reserved.
 *
 * https://www.lamyz.com/
 *
 * 未经允许，不可做商业用途！
 *
 * 版权所有，侵权必究！
 */

package com.lam.mall.app.vo;

import java.io.Serializable;
import java.util.List;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.lam.common.serializer.json.ImgJsonSerializer;
import com.lam.mall.common.util.ProductUtil;
import com.lam.mall.entity.SkuProperties;

//import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

/**
 * @author lam
 */
@Data
public class SkuVo implements Serializable {

    private static final long serialVersionUID = 6457261945829470666L;

    //@Schema(description = "skuId" , required = true)
    private String id;
    //@Schema(description = "价格" , required = true)
    private Double price;
    //@Schema(description = "原价" )
    private Double oriPrice;

    //@Schema(description = "库存(-1表示无穷)" , required = true)
    private Integer stocks;

    //@Schema(description = "sku名称" , required = true)
    private String skuName;

    //@Schema(description = "图片" )
    @JsonSerialize(using = ImgJsonSerializer.class)
    private String pic;

    //@Schema(description = "销售属性组合字符串,格式是p1:v1;p2:v2" , required = true)
    private String properties;
    
    /** sku属性 */
    private List<SkuProperties> propertiesList;
    
    public void convertProperties(boolean reverse) {
    	if(reverse) {
			this.propertiesList = ProductUtil.skuProperties2List(properties);
    		return;
    	}
    	
		properties = ProductUtil.list2SkuProperties(propertiesList);
    }
}
